#include "modelvolume.h"
#include <ctime>

#ifndef VOLUMECONTROL_H
#define VOLUMECONTROL_H

enum ClickCase {
    CLICK_CASE_LOW_X,
    CLICK_CASE_HIGH_X,
    CLICK_CASE_LOW_Y,
    CLICK_CASE_HIGH_Y,
    CLICK_CASE_LOW_Z,
    CLICK_CASE_HIGH_Z
};

class VolumeControl
{
public:
    VolumeControl(int width, int depth, int height);


    bool isMovingForward, isMovingBackward;
    bool isMovingLeft, isMovingRight;
    modelVolume* volume;
    Type toolbar[9];
    int selectedMaterial;
    double translation[3];
    double rotation[3];
    double eye[3];
    double center[3];

    int mouseLeftDraggedX, mouseLeftDraggedY;
    int mouseLeftStartX, mouseLeftStartY;
    int mouseMiddleDraggedX, mouseMiddleDraggedY;
    int mouseMiddleStartX, mouseMiddleStartY;
    int mouseRightDraggedX, mouseRightDraggedY;
    int mouseRightStartX, mouseRightStartY;

    int selectionX, selectionY, selectionZ;
    bool validPosition;

    void frame(clock_t timeDiff);
    void leftClickAction(double x, double y, double z);
    void rightClickAction(double x, double y, double z);
    void incrementType();

    void mouseMoveAction(float posX, float posY, float posZ);

    void mouseLeftMove(int x, int y);
    void mouseLeftDown(int x, int y);
    void mouseLeftUp();

    void mouseMiddleMove(int x, int y);
    void moveSideward(int xDiff);
    void mouseMiddleDown(int x, int y);
    void mouseMiddleUp();

    void mouseRightMove(int x, int y);
    void moveForward(int xDiff);
    void mouseRightDown(int x, int y);
    void mouseRightUp();
};

#endif // VOLUMECONTROL_H
